/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scheduleManager;

import app.Global;
import entities.EmployeeSchedule;
import entities.TimeSlot;
import java.sql.Date;
import lib.JButtonTable.ButtonModel;

/**
 *
 * @author yoshi
 */
public class AssignHeadButtonModel implements ButtonModel {

    private Date date;
    private TimeSlot timeSlot;
    private EmployeeSchedule schedule;

    public AssignHeadButtonModel(Date date, TimeSlot timeSlot, EmployeeSchedule schedule) {
        this.date = date;
        this.timeSlot = timeSlot;
        this.schedule = schedule;
    }

    @Override
    public String getText() {
        if(!Global.getAuth().isManager()){
            return "Not allowed";
        }else if(date.compareTo(new Date(new java.util.Date().getTime())) <= 0){
            return "Passed";
        }else if(schedule == null){
            return "add";
        }else {
            return "delete";
        }
    }

    @Override
    public boolean isEnable() {
        if(!Global.getAuth().isManager()){
            return false;
        }else if(date.compareTo(new Date(new java.util.Date().getTime())) <= 0){
            return false;
        }else{
            return true;
        }
    }

    public Date getDate() {
        return date;
    }

    public EmployeeSchedule getSchedule() {
        return schedule;
    }

    public TimeSlot getTimeSlot() {
        return timeSlot;
    }
}
